package com.cxyd.modules.wcs.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.cxyd.common.service.impl.CrudServiceImpl;
import com.cxyd.common.utils.ConvertUtils;
import com.cxyd.modules.wcs.dao.TcpIpDao;
import com.cxyd.modules.wcs.dto.TcpIpDTO;
import com.cxyd.modules.wcs.entity.TcpIpEntity;
import com.cxyd.modules.wcs.service.TcpIpService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class TcpIpServiceImpl extends CrudServiceImpl<TcpIpDao, TcpIpEntity, TcpIpDTO> implements TcpIpService {
    @Override
    public QueryWrapper<TcpIpEntity> getWrapper(Map<String, Object> params) {
        return null;
    }

    @Override
    public TcpIpDTO getTcpIpByDvcNo(String dvcNo) {
        if (StringUtils.isBlank(dvcNo)) {
            return null;
        }
        QueryWrapper<TcpIpEntity> wrapper = new QueryWrapper<>();
        wrapper.eq("dvc_no", dvcNo)
                .last("LIMIT 1");
        TcpIpEntity entity = baseDao.selectOne(wrapper);
        if (entity == null) {
            return null;
        }
        return ConvertUtils.sourceToTarget(entity, TcpIpDTO.class);
    }
}
